home *** CD-ROM | disk | FTP | other *** search
/ com!online 2005 May / com_0505_1.iso / opensource / top10 / amc_install.exe / {app} / Scripts / ExcaliburFilms.ifs < prev    next >
Encoding:
Text File  |  2004-11-18  |  12.5 KB  |  380 lines

  1. // GETINFO SCRIPTING
  2. // [EN] Excalibur Films Adult DVD v0.2
  3.  
  4. (***************************************************
  5.  *  Movie importation script for:                  *
  6.  *      ExcaliburFilms                             *
  7.  *      http://excaliburfilms.com                  *
  8.  *      http://alldvdmovies.com                    *
  9.  *                                                 *
  10.  *         Written by KaraGarga                    *
  11.  *         karagarga@gmail.com                     *
  12.  *         Script Date: 14.10.2004                 *
  13.  ***************************************************
  14.  *  For use with Ant Movie Catalog 3.4.0           *
  15.  *  www.antp.be/software/moviecatalog              *
  16.  *                                                 *
  17.  *  This program is free software; you can         *
  18.  *  redistribute it and/or modify it under the     *
  19.  *  terms of the GNU General Public License as     *
  20.  *  published by the Free Software Foundation;     *
  21.  *  either version 2 of the License, or (at your   *
  22.  *  option) any later version.                     *
  23.  ***************************************************)
  24.  
  25. program Excalibur;
  26.  
  27. const
  28.     ImportActors = True;
  29.     ImportBigCover = True;
  30.     ImportSmallCover = False;
  31.     ImportCustomerReview = True;
  32.     ImportReview = True;
  33.     ImportLenght = True;
  34.     { True: Related info will be parsed
  35.       False: Related info won't be parsed }
  36. var
  37.   MovieName: string;
  38.   MovieURL: string;
  39.  
  40. function FindLine(Pattern: string; List: TStringList; StartAt: Integer): Integer;
  41. var
  42.   i: Integer;
  43. begin
  44.   result := -1;
  45.   if StartAt < 0 then
  46.     StartAt := 0;
  47.   for i := StartAt to List.Count-1 do
  48.     if Pos(Pattern, List.GetString(i)) <> 0 then
  49.     begin
  50.       result := i;
  51.       Break;
  52.     end;
  53. end;
  54.  
  55. function StringReplaceAll(S, Old, New: string): string;
  56. begin
  57.   while Pos(Old, S) > 0 do
  58.     S := StringReplace(S, Old, New);
  59.   Result := S;
  60. end;
  61.  
  62. procedure CutAfter(var Str: string; Pattern: string);
  63. begin
  64.   Str := Copy(str, Pos(Pattern, Str) + Length(Pattern), Length(Str));
  65. end;
  66.  
  67. procedure CutBefore(var Str: string; Pattern: string);
  68. begin
  69.   Str := Copy(Str, Pos(Pattern, Str), Length(Str));
  70. end;
  71.  
  72. function GetStringFromHTML(Page, StartTag, CutTag, EndTag: string): string;
  73. begin
  74.   Result := '';
  75.   if Pos(StartTag, Page) > 0 then begin
  76.     CutBefore(Page, StartTag);
  77.     if Length(CutTag) > 0 then
  78.       CutAfter(Page, CutTag);
  79.       Result := Copy(Page, 0, Pos(EndTag, Page) - 1);
  80.       HTMLDecode(Result);
  81.   end;
  82. end;
  83.  
  84. procedure AnalyzePage(Address: string);
  85. var
  86.   Page: TStringList;
  87. begin
  88.   Page := TStringList.Create;
  89.   Page.Text := GetPage(Address);
  90.   if pos('DVD Video Movie</TITLE>', Page.Text) > 0 then
  91.   begin
  92.     AnalyzeMoviePage(Page)
  93.   end;
  94.   if pos('<table width="430" align="center" cellpadding="0" cellspacing="0" hspace="0" border="0">', Page.Text) > 0 then
  95.   begin
  96.     PickTreeClear;
  97.     AddMoviesTitles(Page);
  98.     if PickTreeExec(Address) then
  99.     AnalyzePage(Address);
  100.   end;
  101.   if pos('Sorry, no DVD result matches your search.', Page.Text) > 0 then
  102.   begin
  103.   ShowMessage('Sorry, no DVD result matches your search. Please narrow your search criteria.');
  104.   if Input('Excalibur Films: Adult DVD Script 0.1', 'Please enter the title of the movie:', MovieName) then
  105.     begin
  106.       AnalyzePage('http://www.alldvdmovies.com/IndexS2.htm?SearchFor=Title.x&Search=AdultDVDMovies&Case=AllDVDMovies&x=0&y=0&searchString='+UrlEncode(MovieName));
  107.     end;
  108.   end;
  109.   Page.Free;
  110. end;
  111.  
  112. procedure AnalyzeMoviePage(Page: TStringList);
  113. var
  114.   Line, Value, Value2 : string;
  115.   LineNr: Integer;
  116.   BeginPos, EndPos : Integer;
  117. begin
  118.  
  119. // URL--------------------------------------------------------------------------
  120.   LineNr := FindLine('onCLick="location=', Page, 0);
  121.   Line := Page.GetString(LineNr);
  122.   if LineNr > -1 then
  123.   begin
  124.     BeginPos := pos('ck="', Line);
  125.     if BeginPos > 0 then
  126.       BeginPos := BeginPos + 14;
  127.     EndPos := pos('.htm', Line);
  128.     if EndPos = 0 then
  129.       EndPos := Length(Line);
  130.     Value := copy(Line, BeginPos, EndPos - BeginPos - 2);
  131.     HTMLDecode(Value);
  132.     SetField(fieldURL, 'http://excaliburfilms.com/AdultDVD/'+Value+'.htm');
  133.   end;
  134.  
  135.  
  136. //Title-------------------------------------------------------------------------
  137.   LineNr := FindLine('<h2><font color="Navy" class="size20bold">', Page, 0);
  138.   if LineNr > -1 then
  139.   begin
  140.     Value := Page.GetString(LineNr);
  141.     HTMLDecode(Value);
  142.     HTMLRemoveTags(Value);
  143.     SetField(fieldOriginalTitle, Value);
  144.   end;
  145.  
  146. //Sub-Title
  147.   LineNr := FindLine('<font color="Navy" class="size15">', Page, 0);
  148.   if LineNr > -1 then
  149.     begin
  150.     Value2 := Page.GetString(LineNr);
  151.     HTMLDecode(Value2);
  152.     HTMLRemoveTags(Value2);
  153.     SetField(fieldOriginalTitle, Value+' '+Value2);
  154.     end;
  155.   if LineNr < 0 then
  156.     begin
  157.     SetField(fieldOriginalTitle, Value)
  158.     end;
  159.  
  160. // Rating-----------------------------------------------------------------------
  161.   LineNr := FindLine('Customer Rating:</font>', Page, 0);
  162.   if LineNr > -1 then
  163.   begin
  164.     Line := Page.GetString(LineNr + 1);
  165.     if Pos('excal/Stars_', Line) > 0 then
  166.     begin
  167.       BeginPos := pos('Stars_', Line) + 6;
  168.       EndPos := pos('.gif"', Line);
  169.       Value := copy(Line, BeginPos, EndPos - BeginPos);
  170.       Value := StringReplace(Value, '-', ',');
  171.       SetField(fieldRating, Value);
  172.     end;
  173.   end;
  174.  
  175. // Director---------------------------------------------------------------------
  176.   LineNr := FindLine('Director: </font>', Page, 0);
  177.   if LineNr > -1 then
  178.   begin
  179.   Line := Page.GetString(LineNr);
  180.    BeginPos := pos('dana">', Line) + 6;
  181.    EndPos := pos('</FONT>', Line);
  182.       Value := copy(Line, BeginPos, EndPos - BeginPos);
  183.       HTMLDecode(Value);
  184.     SetField(fieldDirector, Value);
  185.   end;
  186.  
  187.  
  188. //Small Picture-----------------------------------------------------------------
  189.   if ImportSmallCover then
  190.     begin
  191.     LineNr := FindLine('<img src="http://images.excaliburfilms.com/dvd/reviews/', Page, 0);
  192.       if LineNr > -1 then
  193.         begin
  194.         Line := Page.GetString(LineNr);
  195.         BeginPos := pos('src="', Line) + 4;
  196.         Delete(Line, 1, BeginPos);
  197.         EndPos := pos('"', Line);
  198.         Value := copy(Line, 1, EndPos - 1);
  199.         HTMLDecode(Value);
  200.         GetPicture(Value, False);
  201.         end;
  202.     end;
  203.  
  204.  
  205. //Big Picture-------------------------------------------------------------------
  206.   if ImportBigCover then
  207.     begin
  208.     LineNr := FindLine('<img src="http://images.excaliburfilms.com/dvd/reviews/', Page, 0);
  209.     if LineNr > -1 then
  210.       begin
  211.       Line := Page.GetString(LineNr);
  212.       BeginPos := pos('src="', Line) + 4;
  213.       Delete(Line, 1, BeginPos);
  214.       EndPos := pos('"', Line);
  215.       Value := copy(Line, 1, EndPos - 1);
  216.       Value := StringReplace(Value, 'T8/', 'T8/largemoviepic/');
  217.       Value := StringReplace(Value, '_dvd.jpg', '.JPG');
  218.       HTMLDecode(Value);
  219.       GetPicture(Value, False);
  220.       end;
  221.     end;
  222.  
  223. //Category----------------------------------------------------------------------
  224.   LineNr := FindLine('Rated: </font>', Page, 0);
  225.   if LineNr > -1 then
  226.   begin
  227.     Line := Page.GetString(LineNr);
  228.     BeginPos := pos('Rated: </font>', Line) + 14;
  229.     EndPos := pos('</a><BR>', Line);
  230.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  231.     HTMLRemoveTags(Value);
  232.     HTMLDecode(Value);
  233.     SetField(fieldCategory, Value);
  234.   end;
  235.  
  236. //Synopsis----------------------------------------------------------------------
  237.   LineNr := FindLine('Synopsis: </font>', Page, 0);
  238.   if LineNr > -1 then
  239.   begin
  240.     Value := Page.GetString(LineNr);
  241.     Value := StringReplace(Value, '<p>', #13#10);
  242.     Value := StringReplace(Value, 'Synopsis: ', '');
  243.     HTMLRemoveTags(Value);
  244.     HTMLDecode(Value);
  245.     SetField(fieldDescription, Value);
  246.   end;
  247.  
  248. // Excalibur Review-------------------------------------------------------------
  249.   if ImportReview then
  250.   begin
  251.   LineNr := FindLine('br clear="all"><font color="black" class="size14verdanabold">Themes:', Page, 0);
  252.   if LineNr > -1 then
  253.   begin
  254.     Value:= GetStringFromHTML(Page.Text, 'class="size14verdanabold">Themes: </font> ', '<font color="Black" class="size14verdana">', '<CENTER>');
  255.     Value := StringReplace(Value, '<br>', #13#10);
  256.     Value := StringReplace(Value, '<p>', #13#10);
  257.     Value := StringReplace(Value, '<P>', #13#10);
  258.     Value := StringReplace(Value, #13#10+' ', #13#10);
  259.     Value := StringReplace(Value, #13#10+#13#10, #13#10);
  260.     HTMLRemoveTags(Value);
  261.     HTMLDecode(Value);
  262.     SetField(fieldComments, Value);
  263.   end;
  264.   end;
  265.  
  266.  
  267. // Customer Review--------------------------------------------------------------
  268.   if ImportCustomerReview then
  269.   begin
  270.   LineNr := FindLine('Customer Reviews:</font>', Page, 0);
  271.   if LineNr > 0 then
  272.     begin
  273.     Value:= GetStringFromHTML(Page.Text, 'Customer Reviews:</font>', '<font color="Black" class="size14verdana">', '</td></tr></table>');
  274.     Value := StringReplace(Value, '<P>', #13#10+#13#10);
  275.     Value := StringReplace(Value, '<BR>', #13#10);
  276.     Value := StringReplace(Value, 'Customer Reviews:', '');
  277.     Value := StringReplace(Value, #13#10+#13#10, #13#10);
  278.     HTMLRemoveTags(Value);
  279.     HTMLDecode(Value);
  280.     SetField(fieldComments, GetField(fieldComments)+'CUSTOMER REVIEW(s):'+Value);
  281.     end;
  282.   end;
  283.  
  284.  
  285. // Length-----------------------------------------------------------------------
  286.   if ImportLenght then
  287.   LineNr := FindLine('Run Time: </font>', Page, 0);
  288.   if LineNr > -1 then
  289.   begin
  290.     Value := Page.GetString(LineNr);
  291.     HTMLRemoveTags(Value);
  292.     HTMLDecode(Value);
  293.     Value := StringReplace(Value, 'Run Time:', '');
  294.     Value := StringReplace(Value, ' ', '');
  295.     Value := StringReplace(Value, 'min.', '');
  296.     SetField(fieldLength, Value);
  297.   end;
  298.  
  299.  
  300. // Actors-----------------------------------------------------------------------
  301.   if ImportActors then
  302.   begin
  303.   LineNr := FindLine('Starring:</font>', Page, 0);
  304.   if LineNr > -1 then
  305.   begin
  306.    Value := Page.GetString(LineNr);
  307.    Value := StringReplace(Value, 'Starring:</font> ', '');
  308.    Value := StringReplace(Value, 'Starring:</font>', '');
  309.    HTMLRemoveTags(Value);
  310.    HTMLDecode(Value);
  311.    SetField(fieldActors, Value);
  312.   end;
  313.   end;
  314.  
  315. //Release Year------------------------------------------------------------------
  316.   LineNr := FindLine('Released: </font>', Page, 0);
  317.   if LineNr > -1 then
  318.   begin
  319.     Line := Page.GetString(LineNr);
  320.     BeginPos := pos('dana">', Line) + 6;
  321.     EndPos := pos(',', Line);
  322.     Value := copy(Line, BeginPos, EndPos - BeginPos);
  323.     SetField(fieldYear, Value);
  324.   end;
  325.  
  326.   DisplayResults;
  327. end;
  328.  
  329.  
  330. procedure AddMoviesTitles(Page: TStringList);
  331. var
  332.   Line, Result: string;
  333.   LineNr: Integer;
  334.   MovieTitle, MovieAddress: string;
  335.   StartPos: Integer;
  336. begin
  337.   LineNr := FindLine('<font class=searchTitle>', Page, 0);
  338.   if LineNr > -1 then
  339.   begin
  340.     LineNr:=FindLine('<font color="White"><b>Records:</b>', Page, 0);;
  341.     Result:= Page.GetString(LineNr+7);
  342.     StartPos := pos('<b>', Result) + 3;
  343.     Result := Copy(Result, StartPos, Pos('</b>', Result) - StartPos);
  344.     PickTreeAdd('Excalibur Films Search >> Number of Results: '+'('+Result+')', '');
  345.     LineNr := FindLine('<table width="430" align="center" cellpadding="0" cellspacing="0" hspace="0" border="0">', Page, 0);
  346.     LineNr := LineNr +2;
  347.     Line := Page.GetString(LineNr);
  348.     repeat
  349.       StartPos := Pos('onMouseout="window.status=''" title="DVD"><font class=searchTitle>', Line) + 1;
  350.       MovieTitle := Copy(Line, StartPos, Pos('</font></a><font class=searchTitle> DVD <a', Line) - StartPos);
  351.       HTMLRemoveTags(MovieTitle);
  352.       HTMLDecode(MovieTitle);
  353.       StartPos := pos('a href=', Line) + 7;
  354.       Delete(Line, 1, StartPos);
  355.       MovieAddress := Copy(Line, 1, pos('" onmouseover=', Line) - 1);
  356.       if MovieTitle <> '' then
  357.       PickTreeAdd(MovieTitle, MovieAddress);
  358.       LineNr := LineNr + 1;
  359.       Line := Page.GetString(LineNr);
  360.       until Pos('<p align="center">', Line) > 0;
  361.     end;
  362. end;
  363.  
  364. begin
  365.   if CheckVersion(3,4,0) then
  366.   begin
  367.     MovieName := GetField(fieldOriginalTitle);
  368.     if MovieName = '' then
  369.       MovieName := GetField(fieldTranslatedTitle);
  370.     if Input('Excalibur Films: Adult DVD Script 0.1', 'Please enter the title of the movie:', MovieName) then
  371.     begin
  372.       AnalyzePage('http://www.alldvdmovies.com/IndexS2.htm?SearchFor=Title.x&Search=AdultDVDMovies&Case=AllDVDMovies&x=0&y=0&searchString='+UrlEncode(MovieName));
  373.     end;
  374.   end
  375.   else
  376.     ShowMessage('This script requires a newer version of Ant Movie Catalog (at least the version 3.4.0)');
  377. end.
  378.  
  379.  
  380.